<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model="username">
        <div v-for="user in users" :key="user.id+user.username">
            <p>id:{{user.id}}</p>
            <p>姓名:{{user.username}}</p>
            <p>地址:{{user.address}}</p>
        </div>
        
            
        
    </div>
    <script src="./js/vue.js"></script>
    <script src="./js/jquery.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                username: '',
                users: [{}]
            },
            watch: {
                username(value) {
                    const baseUrl = "http://wangsr.vip:3000/api/"
                    let url = baseUrl + `users?username_like=${value}`
                    $.get(url).then((data)=>{
                        this.users = data.results.data
                        
                    })
                }
            }
        })
    </script>

</body>

</html>